package com.view.jurisdictionmanage;

import com.bean.Power;
import com.bean.User;
import com.lovo.netCRM.component.LovoButton;
import com.lovo.netCRM.component.LovoTxt;
import com.service.PowerService;
import com.service.RoleService;
import com.service.UserService;
import com.service.impl.PowerServiceImpl;
import com.service.impl.RoleServiceImpl;
import com.service.impl.UserServiceImpl;
import com.util.MyCheckBox;
import com.view.MainFrame;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class RoleShowDialog extends JDialog {

    private LovoButton cancelBtn;


    private JLabel powerLeb;
    private JLabel nameLeb;

    private MainFrame frame ;
    private UserService userService = new UserServiceImpl();
    private RoleService roleService = new RoleServiceImpl();
    private PowerService powerService = new PowerServiceImpl();
    private int key;

    public RoleShowDialog(MainFrame frame,int key) {
        // TODO Auto-generated constructor stub
        super(frame,"添加新用户",true);
        this.frame = frame;
        this.key = key;
        this.setBounds(350, 250, 520, 400);
        this.setLayout(null);
        this.init();
        this.setVisible(true);
    }


    private void init() {
        // TODO Auto-generated method stub

        powerLeb = new JLabel();
        powerLeb.setBounds(50,150,350,150);
        List<Power> powerList = new ArrayList<>();
        powerList = roleService.showRolePower(key);
        powerLeb.setText("<html>拥有权限:"+powerList.toString()+"</html>");
        this.add(powerLeb);


        nameLeb = new JLabel();
        nameLeb.setBounds(50,80,350,50);
        String name = roleService.selectRoleName(key);
        nameLeb.setText("角色 :    "+name+"");
        this.add(nameLeb);





        this.cancelBtn = new LovoButton("取消", 270, 320, this);

        cancelBtn.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                RoleShowDialog.this.dispose();
            }
        });

    }

}
